var logger = require("pomelo-logger").getLogger(__filename);

module.exports = function (app) {
    return new PermissionRemote(app);
};

var PermissionRemote = function (app) {
    this.app = app;
};

// 禁用某个玩家
PermissionRemote.prototype.disable = function (msg, callback) {
    logger.info("disable account msg=" + JSON.stringify(msg));
    if (!msg.hasOwnProperty("uid")) {
        callback({
            resultCode: 404,
            message: "uid为空"
        });
        return;
    }
    var uid = parseInt(msg["uid"]);
    if (uid <= 0) {
        callback({
            resultCode: 404,
            message: "uid 不合法. uid=" + uid
        });
        return;
    }

    if (!msg.hasOwnProperty("disableReason")) {
        callback({
            resultCode: 404,
            message: "disableReason为空"
        });
        return;
    }
    var disableReason = msg["disableReason"];

    var playerService = this.app.get("playerService");
    playerService.disable(uid, disableReason, callback);
};

// 解除禁用某个玩家
PermissionRemote.prototype.enable = function (msg, callback) {
    logger.info("enable account msg=" + JSON.stringify(msg));
    if (!msg.hasOwnProperty("uid")) {
        callback({
            resultCode: 404,
            message: "uid为空"
        });
        return;
    }
    var uid = parseInt(msg["uid"]);
    if (uid <= 0) {
        callback({
            resultCode: 404,
            message: "uid 不合法. uid=" + uid
        });
        return;
    }

    var playerService = this.app.get("playerService");
    playerService.enable(uid, callback);
};





